package com.etc.dao.impl;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.etc.dao.RegionDao;
import com.etc.entity.Region;
import com.etc.util.DBUtil;

public class RegionDaoImpl implements RegionDao{

	@Override
	public List<Region> findAll() {
		List<Region> list = new ArrayList<Region>();
		ResultSet rs = DBUtil.query("SELECT region_id,region_name FROM region");
		try {
			while (rs.next()) {
				Integer regionId = rs.getInt("region_id");
				String regionName = rs.getString("region_name");
				
				Region region = new Region();
				region.setRegionId(regionId);
				region.setRegionName(regionName);
				
				list.add(region);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return list;
	}

}
